<!--头部公共部分-->
{include file="common/header" /}

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form layui-form-pane">
				<fieldset class="layui-elem-field layui-field-title">
				</fieldset>
				<div class="layui-form-item layui-form-text">
					<div class="layui-input-block">
						<textarea placeholder="请输入释放客户的原因" name="reason" class="layui-textarea"></textarea>
					</div>
				</div>
				<fieldset class="layui-elem-field layui-field-title">
				</fieldset>
				<div class="layui-row layui-form-item">
					<div class="layui-input-block" style="float: right;">
						<a class="layui-btn layui-btn-primary" data-type="cancel">取消</a>
						<input type="hidden" name="ids" value="{$ids}">
						<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="form-organization-add">确认</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
	layui.use(['table','element','form', 'layer'], function () {
		let table = layui.table,
			form = layui.form,
			layer = layui.layer,
			element = layui.element,
			$ = layui.$;

		form.on('submit(form-organization-add)', function (data) {
			$.ajax({
				url: "{:url('Customer/release')}",
				type: 'post',
				dataType: 'json',
				data: data.field,
				success: function (res) {
					if (res.code === 1) {
						layer.msg(res.msg, {icon: 1, time: res.wait * 1000}, function () {
							let index = parent.layer.getFrameIndex(window.name); //获取窗口索引
							parent.layer.close(index);  // 关闭layer
							// window.parent.location.reload(); //刷新父页面
						});
					} else {
						layer.msg(res.msg, {icon: 2, time: res.wait * 1000}, function () {
						});
					}
				},
			});
			return false;
		});

		let active = {
			cancel: function () {
				let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭
			},
			reload: function () {
				window.location.reload();
			}
		};

		$('.layui-btn').on('click', function () {
			let type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
	});
</script>
